package com.myapp.api.service.impl;

import com.myapp.api.entity.Admin;
import com.myapp.api.mapper.AdminMapper;
import com.myapp.api.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper mapper;

    @Override
    public List<Admin> getAdmins() {
        return mapper.getAdmins();
    }

    @Override
    public Admin getAdminById(@Param("id") Integer id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public Admin getAdminByAccount(@Param("account") String account) {
        return mapper.getAdminByAccount(account);
    }

    @Override
    public Integer getAdminByOneAccount(@Param("account") String account) {
        return mapper.getAdminByOneAccount(account);
    }

    @Override
    public int addAdmin(@Param("record") Admin record) {
        return mapper.insertSelective(record);
    }

    @Override
    public int deleteAdminById(@Param("id") Integer id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int putAdmin(@Param("record") Admin record) {
        return mapper.updateByPrimaryKey(record);
    }
}
